import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
import { Message,Header,Container,Aside,Main} from 'element-ui'
import './assets/fonts/iconfont.css'
import TreeTable from 'vue-table-with-tree-grid'
//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

//注册富文本编辑器为全局可用的组件
Vue.use(VueQuillEditor, /* { default global options } */)

axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/'
/*axios 请求拦截器添加authorization请求头*/
axios.interceptors.request.use(config=>{
  config.headers.authorization=window.sessionStorage.getItem('token');
  return config;
});
Vue.prototype.$axios=axios
Vue.prototype.$message=Message;

Vue.config.productionTip = false

Vue.use(Header)
Vue.use(Container)
Vue.use(Aside)
Vue.use(Main)
Vue.component('tree-table',TreeTable)

Vue.filter("dataFormat",function (val) {
  var dt=new Date(val);
  var y=dt.getFullYear();
  var m=(dt.getMonth()+1+'').padStart(2,'0');
  var d=(dt.getDate()+'').padStart(2,'0');

  var hh=(dt.getHours()+'').padStart(2,'0');
  var mm=(dt.getMinutes()+'').padStart(2,'0');
  var ss=(dt.getSeconds()+'').padStart(2,'0');

  return y+'-'+m+'-'+d+' '+hh+':'+mm+':'+ss;

})


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
